<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@page import="clicktodial.model.ModelFacade"%>
<%@page import="clicktodial.model.Person"%>
<%@page import="java.util.List"%>

<%--
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link class="css-file" href="css/style.css" id="imitacionCssTelcoblocks" rel="stylesheet" type="text/css" />
        <title>Click To Dial</title>
                <script type="text/javascript" src="${pageContext.request.contextPath}/dojo.js"></script>
        <script type="text/javascript">
            function placeCall(userName) {
                // get data and send to controller servlet
                var bindArgs = {
                    url: "${pageContext.request.contextPath}/placecall?source=${sessionScope.username}&target=" + userName,
                    mimetype: "text/json"
                    };

                dojo.io.bind(bindArgs);      
            }
        </script>
    </head>
    <body>
        <div id="wrapper">

            <div id="banner">
                <h1 class="logo">Click To Dial</h1>
            </div>

            <div id="navigation">
                <ul>
                    <li class="">
                        <a href="http://telcoblocks.germinus.com/inicio;jsessionid=53DD90C08E7DEEECDF9A5B4A6AE0CB23" ><span>Inicio</span></a>
                    </li>
                    <li class="">

                        <a href="http://telcoblocks.germinus.com/objetivos;jsessionid=53DD90C08E7DEEECDF9A5B4A6AE0CB23" ><span>Objetivos</span></a>
                    </li>
                    <li class="">
                        <a href="http://telcoblocks.germinus.com/partners;jsessionid=53DD90C08E7DEEECDF9A5B4A6AE0CB23" ><span>Partners</span></a>
                    </li>
                    <li class="">
                        <a href="http://telcoblocks.germinus.com/enlaces;jsessionid=53DD90C08E7DEEECDF9A5B4A6AE0CB23" ><span>Enlaces</span></a>
                    </li>
                    <li class="selected">
                        <a href="http://telcoblocks.germinus.com/noticias;jsessionid=53DD90C08E7DEEECDF9A5B4A6AE0CB23" ><span>Noticias</span></a>
                    </li>
                    <li class="">
                        <a href="http://telcoblocks.germinus.com/documentos;jsessionid=53DD90C08E7DEEECDF9A5B4A6AE0CB23" ><span>Documentos</span></a>

                    </li>
                  <li class="">
                        <a href="http://telcoblocks.germinus.com/contacto;jsessionid=53DD90C08E7DEEECDF9A5B4A6AE0CB23" ><span>Contacto</span></a>
                    </li>
                </ul>
            </div>

            <div id="content-wrapper">
                <div class="seccion">

                    <span class="titular">
                        <img alt="" src="images/icon.png" />
                        Click To Dial
                    </span>

                    <div class="contenido">
            Usuario conectado: ${sessionScope.username}<br>
            <a href="${pageContext.request.contextPath}/login?logout=true">Log out</a>

              <br>
              <p> A continuaci&oacute;n haga click al usuario que desea llamar </p>
              <br>
            <p>
            Usuarios conectados:
            <table border="1">

                <%
                   ModelFacade model = (ModelFacade) config.getServletContext().getAttribute("Model");
                   List<Person> people = model.getAllPersons();
                   pageContext.setAttribute("people", people);
                %>

                <tr>
                    <td>Nombre</td>
                    <td>SIP URI</td>
                    <td></td>
                </tr>

                <c:forEach var="person" items="${pageScope.people}">
                    <tr>
                    <td>${person.username}</td>
                    <td>${person.telephone}</td>
                    <td>
                        <c:if test="${sessionScope.username ne person.username}">
                            <a href="${pageContext.request.contextPath}/placecall?source=${sessionScope.username}&target=${person.username}" >Call</a>
                        </c:if>
                    </td>
                </c:forEach>
            </table>
            </div>

                </div>
            </div>
            <div id="footer">
            </div>
        </div>

    
    </body>
</html>
